{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>添加用户</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="user_id" value="{$info.user_id}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" placeholder="用户名称" class="layui-input " value="{$info.user_username}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">头像：</label>
                <input type="hidden" name="thumb" id="lay-img" lay-verify="image" value="{$info.user_image}">
                <div class="layui-input-block">
                    <div id="lay-upload">上传图片</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="lay-list">
                            <img class="layui-append-img" src="{$info.image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                        </div>
                    </blockquote>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">性别：</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男" {eq name="$info.user_gender" value="1"}checked{/eq}>
                    <input type="radio" name="sex" value="2" title="女" {eq name="$info.user_gender" value="2"}checked{/eq} >
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">出生日期：</label>
                <div class="layui-input-block">
                    <input type="text" name="birthday" id="birthday" lay-verify="required" placeholder="出生日期" class="layui-input " value="{$info.user_birthday}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">部门：</label>
                <div class="layui-input-block">
                    <select name="department" lay-verify="required" lay-search="">
                        <option value="">请选择部门</option>
                        {foreach name="data" item="vo"}
                        <option value="{$vo.department_id}" {eq name="$info.department_id" value="$vo.department_id"}selected{/eq}>{$vo.department_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">仓库：</label>
                <div class="layui-input-block">
                    <select name="warehouse" lay-verify="required" lay-search="">
                        <option value="">请选择仓库</option>
                        {foreach name="warehouse" item="vo1"}
                        <option value="{$vo1.house_id}" {eq name="$info.warehouse_id" value="$vo1.house_id"}selected{/eq}>{$vo1.warehouse_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">职位：</label>
                <div class="layui-input-block">
                    <input type="text" name="zhiwei" lay-verify="required" placeholder="职位" class="layui-input " value="{$info.user_zhiwei}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">职责：</label>
                <div class="layui-input-block">
                    <input type="text" name="zhize" lay-verify="required" placeholder="职责" class="layui-input " value="{$info.user_zhize}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">密码：</label>
                <div class="layui-input-block">
                    <input type="password" name="password" placeholder="不编辑请留空" class="layui-input " >
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">手机号：</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" lay-verify="required|phone" placeholder="联系方式" class="layui-input " value="{$info.user_phone}">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,url:"{:url('Upload/uploadLocality')}",domain:"{:http_type()}"});
    layui.use(['form','laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate;
        laydate.render({
            elem: '#birthday'
        });
        form.verify({
            image:[/\S/,'请上传图片'],
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('memberEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Appuser/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>